package com.qzy.reggie.mapper;

import com.qzy.reggie.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface Two_CategoryMapper {

    @Select("<script>select * from category" +
            "<where>" +
            "<if test='name != null'> and name = #{name}</if>" +
            "<if test='type != null'> and type = #{type}</if>" +
            "</where>" +
            "</script>")
    List<Category> selectList(Category category);

    @Insert("insert into category (type,name,sort,create_time,update_time,create_user,update_user) values (#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    Integer insert(Category category);

    @Update("<script>" +
            "update category <set>" +
            "<if test='name !=null'>name=#{name},</if>" +
            "<if test='sort !=null'>sort=#{sort},</if>" +
            "</set>" +
            "where id=#{id}" +
            "</script>")
    Integer update(Category category);

    @Select("select * from category where id = #{id}")
    Category selectOne(Category category);

    @Delete("delete from category where id = #{id}")
    Integer delete(Long id);
}
